package Presentacion;

import AccesoDatos.Comando;
import AccesoDatos.Conexion;
import LogicaNegocio.Direccion;
import LogicaNegocio.Nacimiento;
import LogicaNegocio.Telefono;
import java.math.BigDecimal;
import java.sql.ResultSet;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date;
import java.util.HashSet;
import java.util.Set;
import javax.swing.JOptionPane;
import javax.swing.table.DefaultTableModel;

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
/**
 *
 * @author REYES
 */
public class frmConsultaGeneralLocalizaciones extends javax.swing.JInternalFrame {

    Conexion conexion = null;
    Nacimiento nacimiento = new Nacimiento();
    ArrayList<Telefono> vTelefonos = new ArrayList<Telefono>();
    ArrayList<Direccion> vDirecciones = new ArrayList<Direccion>();

    public frmConsultaGeneralLocalizaciones(Nacimiento Pnacimiento, Conexion Pconexion) {
        conexion = Pconexion;
        nacimiento = Pnacimiento;
        vTelefonos = Pnacimiento.getvTelefonos();
        vDirecciones = Pnacimiento.getvDirecciones();
        initComponents();
        cargarNacimiento();
        cargarSalarios();
        jScrollPane11.setVerticalScrollBarPolicy(jScrollPane11.VERTICAL_SCROLLBAR_ALWAYS);
        jScrollPane11.setHorizontalScrollBarPolicy(jScrollPane11.HORIZONTAL_SCROLLBAR_ALWAYS);
        tbDirecciones.getColumnModel().getColumn(0).setPreferredWidth(1500);
        tbDireccionesPatrono.getColumnModel().getColumn(0).setPreferredWidth(1500);
        tbDireccionesPadres.getColumnModel().getColumn(0).setPreferredWidth(1500);
        tbHistoricoSalarial.getColumnModel().getColumn(0).setPreferredWidth(20);
        tbHistoricoSalarial.getColumnModel().getColumn(1).setPreferredWidth(350);
        tbHistoricoSalarial.getColumnModel().getColumn(2).setPreferredWidth(10);
        tbHistoricoSalarial.getColumnModel().getColumn(3).setPreferredWidth(10);

    }

    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jScrollBar1 = new javax.swing.JScrollBar();
        jScrollPane7 = new javax.swing.JScrollPane();
        jTable1 = new javax.swing.JTable();
        jTabbedPane1 = new javax.swing.JTabbedPane();
        jPanel1 = new javax.swing.JPanel();
        jPanel3 = new javax.swing.JPanel();
        jLabel11 = new javax.swing.JLabel();
        jLabel12 = new javax.swing.JLabel();
        jLabel14 = new javax.swing.JLabel();
        jLabel15 = new javax.swing.JLabel();
        txtUltimoPatrono = new javax.swing.JTextField();
        txtTelUltimoPatrono = new javax.swing.JTextField();
        jScrollPane12 = new javax.swing.JScrollPane();
        tbDireccionesPatrono = new javax.swing.JTable();
        jPanel4 = new javax.swing.JPanel();
        lbCedula = new javax.swing.JLabel();
        lbNombre = new javax.swing.JLabel();
        jLabel1 = new javax.swing.JLabel();
        jLabel2 = new javax.swing.JLabel();
        jLabel3 = new javax.swing.JLabel();
        jLabel5 = new javax.swing.JLabel();
        jLabel6 = new javax.swing.JLabel();
        jLabel7 = new javax.swing.JLabel();
        jLabel8 = new javax.swing.JLabel();
        jLabel9 = new javax.swing.JLabel();
        txtTelefonos = new javax.swing.JTextField();
        txtEdad = new javax.swing.JTextField();
        txtFechaNacimiento = new javax.swing.JTextField();
        txtLugarNacimiento = new javax.swing.JTextField();
        txtGenero = new javax.swing.JTextField();
        txtNacionalidad = new javax.swing.JTextField();
        txtNombre = new javax.swing.JTextField();
        txtCedula = new javax.swing.JTextField();
        jScrollPane6 = new javax.swing.JScrollPane();
        txtaOtrosTel = new javax.swing.JTextArea();
        jScrollPane11 = new javax.swing.JScrollPane();
        tbDirecciones = new javax.swing.JTable();
        jPanel5 = new javax.swing.JPanel();
        jLabel13 = new javax.swing.JLabel();
        jLabel16 = new javax.swing.JLabel();
        txtPadre = new javax.swing.JTextField();
        txtMadre = new javax.swing.JTextField();
        jLabel17 = new javax.swing.JLabel();
        jScrollPane13 = new javax.swing.JScrollPane();
        tbDireccionesPadres = new javax.swing.JTable();
        btnSalir = new javax.swing.JButton();
        jPanel2 = new javax.swing.JPanel();
        jScrollPane4 = new javax.swing.JScrollPane();
        tbHistorialCivil = new javax.swing.JTable();
        jPanel6 = new javax.swing.JPanel();
        jScrollPane5 = new javax.swing.JScrollPane();
        tbHistoricoSalarial = new javax.swing.JTable();

        jTable1.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null}
            },
            new String [] {
                "Title 1", "Title 2", "Title 3", "Title 4"
            }
        ));
        jScrollPane7.setViewportView(jTable1);

        setClosable(true);
        setIconifiable(true);

        jTabbedPane1.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N

        jPanel3.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "Patrono", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Tahoma", 0, 14))); // NOI18N

        jLabel11.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N
        jLabel11.setText("Último patrono");

        jLabel12.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N
        jLabel12.setText("Teléfono");

        jLabel14.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N
        jLabel14.setText("Direcciones");

        jLabel15.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N

        txtUltimoPatrono.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N
        txtUltimoPatrono.setHorizontalAlignment(javax.swing.JTextField.RIGHT);

        txtTelUltimoPatrono.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N
        txtTelUltimoPatrono.setHorizontalAlignment(javax.swing.JTextField.RIGHT);

        tbDireccionesPatrono.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N
        tbDireccionesPatrono.setAutoResizeMode(javax.swing.JTable.AUTO_RESIZE_OFF);
        jScrollPane12.setViewportView(tbDireccionesPatrono);

        javax.swing.GroupLayout jPanel3Layout = new javax.swing.GroupLayout(jPanel3);
        jPanel3.setLayout(jPanel3Layout);
        jPanel3Layout.setHorizontalGroup(
            jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel3Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jLabel11)
                    .addComponent(jLabel12)
                    .addComponent(jLabel14)
                    .addComponent(jLabel15))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(txtTelUltimoPatrono)
                    .addComponent(txtUltimoPatrono, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 297, Short.MAX_VALUE)
                    .addComponent(jScrollPane12, javax.swing.GroupLayout.PREFERRED_SIZE, 0, Short.MAX_VALUE))
                .addContainerGap())
        );
        jPanel3Layout.setVerticalGroup(
            jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel3Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel11)
                    .addComponent(txtUltimoPatrono, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel12)
                    .addComponent(txtTelUltimoPatrono, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel3Layout.createSequentialGroup()
                        .addComponent(jLabel14)
                        .addGap(32, 32, 32)
                        .addComponent(jLabel15)
                        .addGap(0, 66, Short.MAX_VALUE))
                    .addComponent(jScrollPane12, javax.swing.GroupLayout.PREFERRED_SIZE, 0, Short.MAX_VALUE))
                .addContainerGap())
        );

        jPanel4.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "Datos personales", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Tahoma", 0, 14))); // NOI18N

        lbCedula.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N
        lbCedula.setText("Cédula");
        lbCedula.setToolTipText("");

        lbNombre.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N
        lbNombre.setText("Nombre");

        jLabel1.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N
        jLabel1.setText("Nacionalidad");
        jLabel1.setToolTipText("");

        jLabel2.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N
        jLabel2.setText("Género");

        jLabel3.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N
        jLabel3.setText("Lugar de nacimiento");

        jLabel5.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N
        jLabel5.setText("Fecha Nacimiento");

        jLabel6.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N
        jLabel6.setText("Edad");

        jLabel7.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N
        jLabel7.setText("Teléfonos propios");
        jLabel7.setToolTipText("");

        jLabel8.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N
        jLabel8.setText("Direcciones");
        jLabel8.setToolTipText("");

        jLabel9.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N
        jLabel9.setText("Otros teléfonos");

        txtTelefonos.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N
        txtTelefonos.setHorizontalAlignment(javax.swing.JTextField.RIGHT);

        txtEdad.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N
        txtEdad.setHorizontalAlignment(javax.swing.JTextField.RIGHT);

        txtFechaNacimiento.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N
        txtFechaNacimiento.setHorizontalAlignment(javax.swing.JTextField.RIGHT);

        txtLugarNacimiento.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N
        txtLugarNacimiento.setHorizontalAlignment(javax.swing.JTextField.RIGHT);

        txtGenero.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N
        txtGenero.setHorizontalAlignment(javax.swing.JTextField.RIGHT);

        txtNacionalidad.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N
        txtNacionalidad.setHorizontalAlignment(javax.swing.JTextField.RIGHT);

        txtNombre.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N
        txtNombre.setHorizontalAlignment(javax.swing.JTextField.RIGHT);

        txtCedula.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N
        txtCedula.setHorizontalAlignment(javax.swing.JTextField.RIGHT);

        txtaOtrosTel.setColumns(20);
        txtaOtrosTel.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N
        txtaOtrosTel.setRows(5);
        jScrollPane6.setViewportView(txtaOtrosTel);

        tbDirecciones.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N
        tbDirecciones.setAutoResizeMode(javax.swing.JTable.AUTO_RESIZE_OFF);
        jScrollPane11.setViewportView(tbDirecciones);

        javax.swing.GroupLayout jPanel4Layout = new javax.swing.GroupLayout(jPanel4);
        jPanel4.setLayout(jPanel4Layout);
        jPanel4Layout.setHorizontalGroup(
            jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel4Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                    .addGroup(jPanel4Layout.createSequentialGroup()
                        .addComponent(jLabel3)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(txtLugarNacimiento))
                    .addGroup(jPanel4Layout.createSequentialGroup()
                        .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(lbCedula)
                            .addComponent(lbNombre)
                            .addComponent(jLabel1)
                            .addComponent(jLabel2))
                        .addGap(59, 59, 59)
                        .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(txtNombre, javax.swing.GroupLayout.Alignment.TRAILING)
                            .addComponent(txtNacionalidad, javax.swing.GroupLayout.Alignment.TRAILING)
                            .addComponent(txtGenero)
                            .addComponent(txtCedula)))
                    .addGroup(jPanel4Layout.createSequentialGroup()
                        .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jLabel5)
                            .addComponent(jLabel6)
                            .addComponent(jLabel7)
                            .addComponent(jLabel8)
                            .addComponent(jLabel9))
                        .addGap(27, 27, 27)
                        .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(txtFechaNacimiento)
                            .addComponent(txtEdad)
                            .addComponent(txtTelefonos)
                            .addComponent(jScrollPane6, javax.swing.GroupLayout.DEFAULT_SIZE, 325, Short.MAX_VALUE)
                            .addComponent(jScrollPane11, javax.swing.GroupLayout.PREFERRED_SIZE, 0, Short.MAX_VALUE))))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );
        jPanel4Layout.setVerticalGroup(
            jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel4Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(lbCedula)
                    .addComponent(txtCedula, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(lbNombre)
                    .addComponent(txtNombre, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel1)
                    .addComponent(txtNacionalidad, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel2)
                    .addComponent(txtGenero, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel3)
                    .addComponent(txtLugarNacimiento, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel5)
                    .addComponent(txtFechaNacimiento, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel6)
                    .addComponent(txtEdad, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel7)
                    .addComponent(txtTelefonos, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jLabel8)
                    .addComponent(jScrollPane11, javax.swing.GroupLayout.PREFERRED_SIZE, 96, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jLabel9)
                    .addComponent(jScrollPane6, javax.swing.GroupLayout.PREFERRED_SIZE, 50, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(77, 77, 77))
        );

        jPanel5.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "Padres", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Tahoma", 0, 14))); // NOI18N

        jLabel13.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N
        jLabel13.setText("Padre");

        jLabel16.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N
        jLabel16.setText("Madre");

        txtPadre.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N
        txtPadre.setHorizontalAlignment(javax.swing.JTextField.RIGHT);

        txtMadre.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N
        txtMadre.setHorizontalAlignment(javax.swing.JTextField.RIGHT);

        jLabel17.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N
        jLabel17.setText("Direcciones");

        tbDireccionesPadres.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N
        tbDireccionesPadres.setAutoResizeMode(javax.swing.JTable.AUTO_RESIZE_OFF);
        jScrollPane13.setViewportView(tbDireccionesPadres);

        javax.swing.GroupLayout jPanel5Layout = new javax.swing.GroupLayout(jPanel5);
        jPanel5.setLayout(jPanel5Layout);
        jPanel5Layout.setHorizontalGroup(
            jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel5Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jLabel13)
                    .addComponent(jLabel16)
                    .addComponent(jLabel17))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 68, Short.MAX_VALUE)
                .addGroup(jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                    .addComponent(txtPadre, javax.swing.GroupLayout.DEFAULT_SIZE, 261, Short.MAX_VALUE)
                    .addComponent(txtMadre)
                    .addComponent(jScrollPane13, javax.swing.GroupLayout.PREFERRED_SIZE, 0, Short.MAX_VALUE))
                .addContainerGap())
        );
        jPanel5Layout.setVerticalGroup(
            jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel5Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel13)
                    .addComponent(txtPadre, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel16)
                    .addComponent(txtMadre, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(14, 14, 14)
                .addGroup(jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jLabel17)
                    .addComponent(jScrollPane13, javax.swing.GroupLayout.PREFERRED_SIZE, 96, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        btnSalir.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N
        btnSalir.setIcon(new javax.swing.ImageIcon(getClass().getResource("/src/imagenes/salir_login.png"))); // NOI18N
        btnSalir.setText("Salir");
        btnSalir.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnSalirActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
        jPanel1.setLayout(jPanel1Layout);
        jPanel1Layout.setHorizontalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jPanel4, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addGap(18, 18, 18)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                            .addComponent(jPanel3, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                            .addComponent(jPanel5, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                        .addContainerGap())
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel1Layout.createSequentialGroup()
                        .addComponent(btnSalir, javax.swing.GroupLayout.PREFERRED_SIZE, 95, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(34, 34, 34))))
        );
        jPanel1Layout.setVerticalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jPanel4, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addComponent(jPanel3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(jPanel5, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(29, 29, 29)
                        .addComponent(btnSalir, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)))
                .addContainerGap(23, Short.MAX_VALUE))
        );

        jTabbedPane1.addTab("Información General", jPanel1);

        tbHistorialCivil.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N
        tbHistorialCivil.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {
                {null, null, null, null, null, null},
                {null, null, null, null, null, null},
                {null, null, null, null, null, null}
            },
            new String [] {
                "Cédula", "Nombre", "Tipo Matrimonio", "Tipo Relación", "Fecha", "Duración"
            }
        ));
        jScrollPane4.setViewportView(tbHistorialCivil);

        javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2);
        jPanel2.setLayout(jPanel2Layout);
        jPanel2Layout.setHorizontalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel2Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jScrollPane4, javax.swing.GroupLayout.DEFAULT_SIZE, 939, Short.MAX_VALUE)
                .addContainerGap())
        );
        jPanel2Layout.setVerticalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel2Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jScrollPane4, javax.swing.GroupLayout.PREFERRED_SIZE, 200, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(366, Short.MAX_VALUE))
        );

        jTabbedPane1.addTab("Historial Civil", jPanel2);

        tbHistoricoSalarial.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N
        jScrollPane5.setViewportView(tbHistoricoSalarial);

        javax.swing.GroupLayout jPanel6Layout = new javax.swing.GroupLayout(jPanel6);
        jPanel6.setLayout(jPanel6Layout);
        jPanel6Layout.setHorizontalGroup(
            jPanel6Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel6Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jScrollPane5, javax.swing.GroupLayout.DEFAULT_SIZE, 939, Short.MAX_VALUE)
                .addContainerGap())
        );
        jPanel6Layout.setVerticalGroup(
            jPanel6Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel6Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jScrollPane5, javax.swing.GroupLayout.PREFERRED_SIZE, 140, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(426, Short.MAX_VALUE))
        );

        jTabbedPane1.addTab("Historico Salarial", jPanel6);

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jTabbedPane1)
                .addContainerGap())
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jTabbedPane1)
                .addGap(1, 1, 1))
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void btnSalirActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnSalirActionPerformed
        this.dispose();
    }//GEN-LAST:event_btnSalirActionPerformed

    public void cargarNacimiento() {

        txtCedula.setText(String.valueOf(nacimiento.getCedula())); // Se carga la cedula
        txtNombre.setText(nacimiento.getNombre() + " " + nacimiento.getApellido1() + " " + nacimiento.getApellido2()); // Se carga el nombre
        // Se carga la nacionalidad
        switch ((int) nacimiento.getNacionalidad()) {
            case 0:
                txtNacionalidad.setText("COSTARRICENSE");
                break;
            case 1:
                txtNacionalidad.setText("POR OPCIÓN");
                break;
            case 2:
                txtNacionalidad.setText("NATURALIZADO");
                break;
            case 3:
                txtNacionalidad.setText("NO INDICA");
                break;
            case 4:
                txtNacionalidad.setText("CONSERVA NACIONALIDAD EXTRANJERA");
                break;
            case 5:
                txtNacionalidad.setText("CONSERVA NACIONALIDAD COSTARRICENSE");
                break;
        }
        // si es 1 el sexo es masculino, si es 2 el sexo es femenino
        if (nacimiento.getSexo() == 1) {
            txtGenero.setText("MASCULINO");
        } else {
            txtGenero.setText("FEMENINO");
        }
        // Calculo de la edad
        try {
            int fechaEntrada = (int) nacimiento.getFec_suceso();  // Se obtiene la fecha del objeto nacimiento
            java.util.Date fechaActual = new Date();  // Se obtiene la fecha actual
            DateFormat df = new SimpleDateFormat("yyyyMMdd"); // se lee el formato de la fecha del objeto nacimiento
            Date date = df.parse(String.valueOf(fechaEntrada)); // Se convierte la fecha de nacimiento a date
            DateFormat sdf = new SimpleDateFormat("dd/MM/yyyy"); // Damos formato a la fecha para mostrarlo en el txtFechaNacimiento
            String fecha = sdf.format(date);   // Se le da formato a la fecha
            txtFechaNacimiento.setText(fecha); // Se le asigna la fecha formateada al campo de texto
            txtEdad.setText(Integer.toString(calcularEdad(date, fechaActual)));  // Se le asigna la edad al campo de texto, calculando la edad al mismo tiempo
        } catch (Exception ex) {
            JOptionPane.showMessageDialog(null, ex.getMessage(), null, JOptionPane.ERROR_MESSAGE);
        }
        txtLugarNacimiento.setText(nacimiento.getLugar_nacimiento());
        String tel = "";
        for (int i = 0; i < vTelefonos.size(); i++) {
            BigDecimal numTel = new BigDecimal(vTelefonos.get(i).getTEL());
            tel += String.valueOf(numTel) + ", ";
        }
        txtTelefonos.setText(tel);
        cargarTbDirecciones();
        cargarTbDireccionesPadres();
        txtPadre.setText(nacimiento.getPadre());
        txtMadre.setText(nacimiento.getMadre());

    }

    public void cargarSalarios() {

        DefaultTableModel modelo = new DefaultTableModel();
        modelo.addColumn("Cédula Jurídica");
        modelo.addColumn("Patrono");
        modelo.addColumn("Fecha");
        modelo.addColumn("Salario aproximado");
        tbHistoricoSalarial.setModel(modelo);
        DefaultTableModel modelo2 = new DefaultTableModel();
        modelo2.addColumn("Descripción");
        tbDireccionesPatrono.setModel(modelo2);
        System.out.println(String.valueOf(nacimiento.getCedula()));
        try {
            Comando comando = new Comando("SELECT * FROM tb_salarios WHERE CEDULA = '" + String.valueOf(nacimiento.getCedula()) + "' ORDER BY FECHA DESC");
            ResultSet rs = comando.ejecutarSQL(conexion);
            if (rs.next()) {
                rs.beforeFirst();
                int i = 0; // indice para obtener el ultimo patrono
                while (rs.next()) {
                    Object[] fila = new Object[4]; // Hay cuatro columnas en la tabla  
                    if (i == 0) {
                        cargarUltimoPatrono(String.valueOf(rs.getBigDecimal("JURIDICA")));
                    }
                    fila[0] = String.valueOf(rs.getBigDecimal("JURIDICA"));
                    fila[1] = rs.getString("NOM_PAT");
                    fila[2] = rs.getDate("FECHA");
                    fila[3] = rs.getDouble("PDO1");
                    modelo.addRow(fila);
                    i++;
                }
            }
        } catch (Exception ex) {
            JOptionPane.showMessageDialog(null, ex.getMessage(), null, JOptionPane.ERROR_MESSAGE);
        }

    }

    public void cargarUltimoPatrono(String cedJuridica) {

        DefaultTableModel modelo = new DefaultTableModel();
        modelo.addColumn("Descripción");
        tbDireccionesPatrono.setModel(modelo);
        try {
            Comando comando = new Comando("SELECT * FROM tb_patrono WHERE JURIDICA = '" + cedJuridica + "'");
            Comando comando2 = new Comando("SELECT * FROM tb_direcciones WHERE CEDULA = '" + cedJuridica + "'");
            ResultSet rs = comando.ejecutarSQL(conexion);
            ResultSet rs2 = comando2.ejecutarSQL(conexion);
            if (rs.next()) {
                txtUltimoPatrono.setText(rs.getString("NOM_PAT"));
                txtTelUltimoPatrono.setText(rs.getString("TEL_PAT"));
            }
            while (rs2.next()) {
                Object[] fila = new Object[1];
                fila[0] = rs2.getString("DIREC_LOCA");
                modelo.addRow(fila);
            }

        } catch (Exception ex) {
            JOptionPane.showMessageDialog(null, ex.getMessage(), null, JOptionPane.ERROR_MESSAGE);
        }

    }

    public void cargarTbDirecciones() {

        DefaultTableModel modelo = new DefaultTableModel();
        modelo.addColumn("Descripción");
        tbDirecciones.setModel(modelo);
        Object[] fila = new Object[1];
        ArrayList<String> vTelsEnDir = new ArrayList<String>();
        if (vDirecciones.size() > 0) {
            for (int i = 0; i < vDirecciones.size(); i++) {  //Llenamos el vector de telefonos con los telefonos de las direcciones
                vTelsEnDir.add(vDirecciones.get(i).getTEL1());
                vTelsEnDir.add(vDirecciones.get(i).getTEL2());
                vTelsEnDir.add(vDirecciones.get(i).getTEL3());
                vTelsEnDir.add(vDirecciones.get(i).getTEL4());
            }
            Set duplicados = new HashSet(vTelsEnDir); // Esta linea elimina los telefonos duplicados en el vector de telefonos de las direcciones
            Object[] Tels = new Object[duplicados.size()];
            Tels = duplicados.toArray();
            for (int i = 0; i < vDirecciones.size(); i++) {
                fila[0] = vDirecciones.get(i).getDIREC_LOCA(); // Se crea la fila que contiene la informacion de la direccion para luego agregarla al jtable
                if (Tels[i] != "0") { // Si el telefono es nulo o igual a 0, no lo agrega al area de texto
                    txtaOtrosTel.append(Tels[i] + ", ");
                }
                modelo.addRow(fila);
            }
        }
    }

    public void cargarTbDireccionesPadres() {
        DefaultTableModel modelo = new DefaultTableModel();
        modelo.addColumn("Descripción");
        tbDireccionesPadres.setModel(modelo);
        if (nacimiento.getCedula1() != 0) {
            try {
                Comando comando = new Comando("SELECT * FROM tb_direcciones WHERE CEDULA = '" + nacimiento.getCedula1() + "'");
                ResultSet rs = comando.ejecutarSQL(conexion);
                while (rs.next()) {
                    Object[] fila = new Object[1];
                    fila[0] = rs.getString("DIREC_LOCA");
                    modelo.addRow(fila);
                }

            } catch (Exception ex) {
                JOptionPane.showMessageDialog(null, ex.getMessage(), null, JOptionPane.ERROR_MESSAGE);
            }
        }
        if (nacimiento.getCedula2() != 0) {
            try {
                Comando comando = new Comando("SELECT * FROM tb_direcciones WHERE CEDULA = '" + nacimiento.getCedula2() + "'");
                ResultSet rs = comando.ejecutarSQL(conexion);
                while (rs.next()) {
                    Object[] fila = new Object[1];
                    fila[0] = rs.getString("DIREC_LOCA");
                    modelo.addRow(fila);
                }

            } catch (Exception ex) {
                JOptionPane.showMessageDialog(null, ex.getMessage(), null, JOptionPane.ERROR_MESSAGE);
            }

        }

    }

    public int calcularEdad(Date fechaNacimiento, Date fechaActual) {  // Metodo que calcula la edad apartir de la fecha de nacimiento y la fecha actual
        Calendar fechaAct = Calendar.getInstance();
        fechaAct.setTime(fechaActual);

        Calendar fechaNac = Calendar.getInstance();
        fechaNac.setTime(fechaNacimiento);

        int dif_anios = fechaAct.get(Calendar.YEAR) - fechaNac.get(Calendar.YEAR);
        int dif_meses = fechaAct.get(Calendar.MONTH) - fechaNac.get(Calendar.MONTH);
        int dif_dias = fechaAct.get(Calendar.DAY_OF_MONTH) - fechaNac.get(Calendar.DAY_OF_MONTH);

        //Si está en ese año pero todavía no los ha cumplido
        if (dif_meses < 0 || (dif_meses == 0 && dif_dias < 0)) {
            dif_anios--;
        }
        return dif_anios;
    }
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton btnSalir;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel11;
    private javax.swing.JLabel jLabel12;
    private javax.swing.JLabel jLabel13;
    private javax.swing.JLabel jLabel14;
    private javax.swing.JLabel jLabel15;
    private javax.swing.JLabel jLabel16;
    private javax.swing.JLabel jLabel17;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel5;
    private javax.swing.JLabel jLabel6;
    private javax.swing.JLabel jLabel7;
    private javax.swing.JLabel jLabel8;
    private javax.swing.JLabel jLabel9;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JPanel jPanel2;
    private javax.swing.JPanel jPanel3;
    private javax.swing.JPanel jPanel4;
    private javax.swing.JPanel jPanel5;
    private javax.swing.JPanel jPanel6;
    private javax.swing.JScrollBar jScrollBar1;
    private javax.swing.JScrollPane jScrollPane11;
    private javax.swing.JScrollPane jScrollPane12;
    private javax.swing.JScrollPane jScrollPane13;
    private javax.swing.JScrollPane jScrollPane4;
    private javax.swing.JScrollPane jScrollPane5;
    private javax.swing.JScrollPane jScrollPane6;
    private javax.swing.JScrollPane jScrollPane7;
    private javax.swing.JTabbedPane jTabbedPane1;
    private javax.swing.JTable jTable1;
    private javax.swing.JLabel lbCedula;
    private javax.swing.JLabel lbNombre;
    private javax.swing.JTable tbDirecciones;
    private javax.swing.JTable tbDireccionesPadres;
    private javax.swing.JTable tbDireccionesPatrono;
    private javax.swing.JTable tbHistorialCivil;
    private javax.swing.JTable tbHistoricoSalarial;
    private javax.swing.JTextField txtCedula;
    private javax.swing.JTextField txtEdad;
    private javax.swing.JTextField txtFechaNacimiento;
    private javax.swing.JTextField txtGenero;
    private javax.swing.JTextField txtLugarNacimiento;
    private javax.swing.JTextField txtMadre;
    private javax.swing.JTextField txtNacionalidad;
    private javax.swing.JTextField txtNombre;
    private javax.swing.JTextField txtPadre;
    private javax.swing.JTextField txtTelUltimoPatrono;
    private javax.swing.JTextField txtTelefonos;
    private javax.swing.JTextField txtUltimoPatrono;
    private javax.swing.JTextArea txtaOtrosTel;
    // End of variables declaration//GEN-END:variables
}
